package day1.zy;

import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class Gongshi {
    String mc;
    String dz;
    String hm;
    String fw;
    List<Yuangong> y = new LinkedList<>();

    public boolean add(Yuangong yu) {
        for (int i = 0; i < y.size(); i++){
            Yuangong yuangong =y.get(i);
        if (yuangong.getGonghao().equals(yu.getGonghao())){
            System.out.println("员工号重复");
        }
        }
            y.add(yu);


        return true;
    }

    public void show() {
        ;
        System.out.println("公司名称" + mc);
        System.out.println("注册地址" + dz);
        System.out.println("电话" + hm);
        System.out.println("经营范围" + fw);
        for (int i = 0; i < y.size(); i++) {
            Yuangong yuangong =y.get(i);
            if (yuangong.getName() == null) {
                break;
            } else {
                System.out.println("姓名" + yuangong.getName());
                System.out.println("年龄" + yuangong.getAge());
                System.out.println("性别" + yuangong.getSex());
                System.out.println("职务" + yuangong.getZhiwu());
                System.out.println("薪水" + yuangong.getXinshui());
                System.out.println("工号" + yuangong.getGonghao());
            }
        }

    }

    public boolean fire(String name) {
        for (int i = 0; i < y.size(); i++) {
            Yuangong yuangong = y.get(i);
            if (yuangong.getName().equals(name)) {
                y.remove(yuangong);
                return true;
            }
        }
            return false;

    }
    public void old(){
        Yuangong yuangong = Collections.max(y);
        System.out.println("姓名" + yuangong.getName());
        System.out.println("年龄" + yuangong.getAge());
        System.out.println("性别" + yuangong.getSex());
        System.out.println("职务" + yuangong.getZhiwu());
        System.out.println("薪水" + yuangong.getXinshui());
        System.out.println("工号" + yuangong.getGonghao());
        yuangong.setXinshui(yuangong.getXinshui()+1000);
        System.out.println("加薪后"+yuangong.getXinshui());

    }
}
